/**
 * 
 */
package gui;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.ArrayList;

import javax.swing.JPanel;

import components.Ball;

/**
 * The panel that draws the balls.
 */
public class BallPanel extends JPanel
{

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = -1785034903024731486L;

	private ArrayList<Ball> balls = new ArrayList<Ball>();

	/**
	 * Add a ball to the panel.
	 * 
	 * @param b the ball to add
	 */
	public void add(Ball b)
	{
		this.balls.add(b);
	}

	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		Graphics2D g2 = (Graphics2D) g;
		for (Ball b : this.balls)
		{
			g2.fill(b.getShape());
		}
	}
}
